package Xiancheng;

import java.util.Calendar;
import java.util.Date;

/**
 * callenda的测试类
 * @author AcerMr
 *
 */
public class CallendatMain
{
	public static void main(String[] args)
	{
		System.out.println("========");
		Calendar cal = Calendar.getInstance();
		System.out.println(cal);
		Date da = cal.getTime();
		System.out.println(da.toLocaleString());
		/*获取每个字段*/
		System.out.println("年"+cal.get(Calendar.YEAR));
		System.out.println("月"+cal.get(Calendar.MONTH));
		System.out.println("日"+ cal.get(Calendar.DATE));
		System.out.println("时"+cal.get(Calendar.HOUR_OF_DAY));
		System.out.println("分"+cal.get(Calendar.MINUTE));
		System.out.println("秒"+cal.get(Calendar.SECOND));
		System.out.println("毫秒"+cal.get(Calendar.MILLISECOND));
		System.out.println("一周的第几天"+ cal.get(Calendar.DAY_OF_WEEK));
		System.out.println("一年的第几天"+cal.get(Calendar.DAY_OF_YEAR));
		/*=======================*/
		cal.set(Calendar.DATE, 2);
		da = cal.getTime();
		System.out.println(da.toLocaleString());
		cal.add(cal.DATE, -200);
		da = cal.getTime();
		System.out.println(da.toLocaleString());
		Calendar cal1 = Calendar.getInstance();
		cal1.set(Calendar.DATE,1);
		Date da1 = cal1.getTime();
		cal.before(cal1);
		System.out.println(cal.before(cal1));
		cal.setTime(new Date());
		cal.setTimeInMillis(10000);
		cal.set(2017, 1,1);
		da1 = cal.getTime();
		System.out.println(da1.toLocaleString());
		System.out.println(da1);
		
		
	}
}
